package com.situ.gcbs.server.util;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 功能：异常工具类
 *
 * @author 千堆雪
 * @version 1.0.0
 * @since 2024/5/16
 * <p>
 * created by 千堆雪 on 2024/5/16 10:19, last modified by 千堆雪 on 2024/5/16 10:19
 */
public abstract class Exceptions {
    /**
     * 将异常堆栈转化为字符串
     *
     * @param ex 异常对象
     * @return 异常字符串
     */
    public static String toString(Throwable ex) {
        StringWriter stackTrace = new StringWriter();
        ex.printStackTrace(new PrintWriter(stackTrace));
        stackTrace.flush();
        return stackTrace.toString();
    }
}
